package com.example.task01_demo01;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "HelloServlet4",urlPatterns="/hello4")
public class HelloServlet4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("Get请求方式!");
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("Post请求方式!");
    }

/*    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("原来使用注解的方法可以如此潇洒!");
        String method = req.getMethod();
        System.out.println("获得到的请求方式是:"+method);
        if("get".equalsIgnoreCase(method)){
            doGet(req,resp);
        }
        if("post".equalsIgnoreCase(method)){
            doPost(req,resp);
        }
    }*/
}
